﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Module;
using LPV_POS.mh_pos.mh_cauhinh;
using LPV_POS;
using System.Resources;
using System.Globalization;
//using System.IO;

namespace LPV_POS.mh_pos
{
    public partial class mh_main : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        string str_lang = "";
        string str_thongbao = "";
        thuvien tv;
        string[] s;
        object[] o;

        DataTable tb;
        #region "Muti language"
        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_main).Assembly);
                lbel_1.Text = rm.GetString("banhang", culture);
                lbel_2.Text = rm.GetString("caidat", culture);
                lbel_3.Text = rm.GetString("Baocao", culture);
                lbel_4.Text = rm.GetString("vaoca", culture);
                lbel_5.Text = rm.GetString("quanlykho", culture);
                lbel_5.Font = new Font(lbel_5.Font.Name, 43);
                lbel_6.Text = rm.GetString("raca", culture);
                lbel_7.Text = rm.GetString("danhsachtralai", culture);
                lbel_7.Font = new Font(lbel_7.Font.Name, 42);
                lbel_8.Text = rm.GetString("thaydoingaylamviec", culture);
                lbel_8.Font = new Font(lbel_8.Font.Name, 42);
                lbel_9.Text = rm.GetString("thuchi", culture);
                lbel_12.Text = rm.GetString("thoat", culture);
                lbel_ngaylamviec.Tag = rm.GetString("ngaylamviec", culture);// +" " + Variable.ngay_lamviec.ToString("dd/MM/yyyy"); ;
                //lbel_ngaylamviec.Text = rm.GetString("ngaylamviec", culture) + " " + Variable.ngay_lamviec.ToString("dd/MM/yyyy"); ;



            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion
        #region  cac ham va phuong thuc

        private DateTime f_ngayhienhanh()
        {
            try
            {
                DataTable tb = new thuvien().SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new object[] { "SELECT GETDATE()" });

                return (DateTime)tb.Rows[0][0];
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            return new DateTime(0);
        }
        //-- 20101015
        private DataTable f_dschunang()
        {
            s = new string[] { "@flag", "@choose" };
            o = new object[] { 1, 1 };
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_mhcauhinhchunang", s, o);
            return tb;
        }
        private string f_getnamecompany()
        {
            tv = new thuvien();
            string tencongty = "";
            string[] s = new string[] { "@flag", "@choose" };
            object[] o = new object[] { 1, 1 };
            tb = tv.SP_SelectDataTable("sp_mhcompany", s, o);
            if (tb.Rows.Count > 0)
                tencongty = tb.Rows[0]["TENCONGTY"] + "";
            return tencongty;
        }

        private void set_datalabel(Label lbel_control, DataTable tb, int i)
        {
            byte font_r = byte.Parse(tb.Rows[i]["FONT_COLOR_R"] + "");
            byte font_g = byte.Parse(tb.Rows[i]["FONT_COLOR_G"] + "");
            byte font_b = byte.Parse(tb.Rows[i]["FONT_COLOR_B"] + "");
            byte back_r = byte.Parse(tb.Rows[i]["BGROUND_COLOR_R"] + "");
            byte back_g = byte.Parse(tb.Rows[i]["BGROUND_COLOR_G"] + "");
            byte back_b = byte.Parse(tb.Rows[i]["BGROUND_COLOR_B"] + "");

            lbel_control.Tag = tb.Rows[i]["INDEX_FUNCTION"] + "" + tb.Rows[i]["FUNCTION_NAME"] + "";
            lbel_control.Text = tb.Rows[i]["FUNCTION_SHORT"] + "";
            lbel_control.Font = new Font(tb.Rows[i]["FONT"] + "", (float.Parse(tb.Rows[i]["FONT_SIZE"] + "")*2));
            lbel_control.ForeColor = System.Drawing.Color.FromArgb(font_r, font_g, font_b);
            lbel_control.BackColor = System.Drawing.Color.FromArgb(back_r, back_g, back_b);
        }
        //--
        private void Addform(Form f)
        {
            bool exist = false;
            Form selform = null;
            Form[] frms = this.MdiChildren;
            foreach (Form frm in frms)
            {
                if (frm.Name == f.Name)
                {
                    exist = true;
                    selform = frm;
                    break;
                }
            }
            if (exist)
                selform.Activate();
            else
            {
                f.MdiParent = this;
                f.WindowState = FormWindowState.Maximized;
                f.Show();
            }
        }

        string LoadCaLamViec()
        {
            string sSQL = "";

            //sSQL = "SELECT * FROM DM_DANGNHAP WHERE OBJCODE LIKE '" + Variable.calamviec + "'";
            sSQL = "SELECT * FROM DM_DANGNHAP WHERE USERNAME LIKE '" + Variable.username + "'";

            DataTable tbCalamviec = tv.SP_SelectDataTable("sp_executesql", new string[] { "@sSQL" }, new object[] { sSQL });
            if (tbCalamviec.Rows.Count >0)
            {
                //lblVaoCa.Text = "Ra\nCa";
                return tbCalamviec.Rows[0]["OBJNAME"] + "";
            }
            return "";
        }

        private void label_click(string index)
        {
            if (Variable.username != "" && index !="d" && index !="f")
            {
                Boolean iKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH = false;
                Boolean.TryParse(Variable.tbBH_CAU_HINH.Rows[0]["KHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH"] + "", out iKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH);
                if (!iKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH)
                {
                    mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                    omh_banhang_dangnhap.ShowDialog();
                    if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                        return;
                }
            }

            switch (index)
            {
                case "a"://
                    #region "   ban hàng"
                    if (Variable.username == "")
                    {
                        mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                        omh_banhang_dangnhap.ShowDialog();
                        if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                            break;
                    }
                    int iHINH_THUC_BAN_HANG = 0;
                    int.TryParse(Variable.tbBH_CAU_HINH.Rows[0]["HINH_THUC_BAN_HANG_combo"] + "", out iHINH_THUC_BAN_HANG);

                    int iGIOI_HAN_MON = 0;
                    int.TryParse(Variable.tbBH_CAU_HINH.Rows[0]["GIOI_HAN_MON"] + "", out iGIOI_HAN_MON);
                    if (iGIOI_HAN_MON > 0)
                    {
                        DataTable tb = new thuvien().SP_SelectDataTable("SP_EXECUTESQL",
                                                        new string[] { "@sSQL" },
                                                        new object[] { "SELECT COUNT(*) FROM DM_HH dh" });
                        if (tb.Rows.Count > 0)
                        {
                            if (int.Parse(tb.Rows[0][0] + "") > iGIOI_HAN_MON)
                            {
                                MessageBox_LPV.Show("Số lượng hàng hóa đã vượt quá giới hạn\n" + tb.Rows[0][0] + ">" + iGIOI_HAN_MON);
                                return;
                            }
                        }
                    }
                    if (iHINH_THUC_BAN_HANG == 1)
                    {
                        mh_banhang omh_banhang = new mh_banhang(lbel_tencongty.Text);
                        omh_banhang.ShowInTaskbar = false;
                        omh_banhang.ShowDialog();
                    }
                    else if (iHINH_THUC_BAN_HANG == 0 || iHINH_THUC_BAN_HANG == 2)
                    {
                        mh_banhang_CT omh_banhang_CT = new mh_banhang_CT(lbel_tencongty.Text, this.LoadCaLamViec(), -1);
                        omh_banhang_CT.ShowDialog();
                    }
                    break;
                    #endregion
                case "b"://
                    #region "   cai_dat"
                    if (Variable.username == "")
                    {
                        mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                        omh_banhang_dangnhap.ShowDialog();
                        if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                        {
                            string sSQL = "SELECT * FROM DM_DANGNHAP dd";
                            DataTable tb = new thuvien().SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new object[] { sSQL });
                            if (tb != null)
                            {
                                if (tb.Rows.Count == 0)
                                {
                                    this.Cursor = Cursors.WaitCursor;
                                    mh_dangnhap_MENU omh_dangnhap_MENU = new mh_dangnhap_MENU();
                                    this.Cursor = Cursors.Default;
                                    omh_dangnhap_MENU.ShowDialog();
                                    this.Dispose();
                                    return;
                                }
                            }
                            else
                                break;
                        }
                    }
                    if (new cpublic().KiemTra_CoQuyen(this.Name, "b", 2))//20101215
                    {
                        mh_chedocaidat frm_chedocaidat = new mh_chedocaidat();
                        frm_chedocaidat.Show();
                    }
                    else
                    {
                        switch (str_lang)
                        {
                            case "vi-VN":
                                str_thongbao = "Bạn không có quyền";
                                break;
                            case "en-US":
                                str_thongbao = "You have no power";
                                break;
                        }
                        MessageBox_LPV.Show(str_thongbao);
                    }
                        
                    break;
                    #endregion
                case "c"://
                    #region "   bao cao"
                    if (Variable.username == "")
                    {
                        mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                        omh_banhang_dangnhap.ShowDialog();
                        if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                            break;
                    }
                    baocaodoanhthu frm_baocaodoanhthu = new baocaodoanhthu();
                    frm_baocaodoanhthu.Show();
                    break;
                    #endregion
                case "d"://
                    #region "   VAO CA"
                    new mh_dangnhap().ShowDialog();
                    break;
                    #endregion
                case "e"://
                    #region "   quan ly kho"
                    mh_quanlykho frm_quanlykho = new mh_quanlykho();
                    frm_quanlykho.Show();
                    break;
                    #endregion
                case "f"://
                    #region "   ra ca"
                    {
                        switch (str_lang)
                        {
                            case "vi-VN":
                                str_thongbao = "Bạn đã thoát ca làm việc.\n";
                                break;
                            case "en-US":
                                str_thongbao = "You have gone out.\n";
                                break;
                        }
                        MessageBox_LPV.Show(str_thongbao + SystemInformation.ComputerName);
                    }                    
                    break;
                    #endregion
                case "g"://
                    #region "   danh sach tra lai"
                    if (Variable.username == "")
                    {
                        mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                        omh_banhang_dangnhap.ShowDialog();
                        if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                            break;
                    }
                    if (new cpublic().KiemTra_CoQuyen(this.Name, "g", 2))//20101215
                    {
                        mh_danhsachtrahang frm_danhsachtrahang = new mh_danhsachtrahang();
                        frm_danhsachtrahang.Show();
                    }
                    else
                    {
                        switch (str_lang)
                        {
                            case "vi-VN":
                                str_thongbao = "Bạn không có quyền";
                                break;
                            case "en-US":
                                str_thongbao = "You have no power";
                                break;
                        }
                        MessageBox_LPV.Show(str_thongbao);
                    }
                        
                    break;
                    #endregion
                case "h"://
                    #region "   thay doi ngay lam viec"
                    mh_thaydoingaylamviec frm_thaydoingaylamviec = new mh_thaydoingaylamviec();
                    frm_thaydoingaylamviec.Show();
                    break;
                    #endregion
                case "k":// 
                    #region "   thu chi"
                    if (Variable.username == "")
                    {
                        mh_banhang_dangnhap omh_banhang_dangnhap = new mh_banhang_dangnhap();
                        omh_banhang_dangnhap.ShowDialog();
                        if (omh_banhang_dangnhap.DialogResult != DialogResult.OK)
                            break;
                    }
                    mh_thuchi frm_thuchi = new mh_thuchi();
                    frm_thuchi.Show();
                    break;
                    #endregion
                case "l":
                    #region "   Thoat"
                    switch (str_lang)
                    {
                        case "vi-VN":
                            str_thongbao = "Bạn muốn thoát chương trình?";
                            break;
                        case "en-US":
                            str_thongbao = "Do you exit the program?";
                            break;
                    }

                    DialogResult dlg = MessageBox_LPV.Show(str_thongbao, MessageBox_LPV.chon.OkCancel);
                    if (dlg==DialogResult.OK)
                    {
                        this.Close();
                    }
                    break;
                    #endregion
            }

        }
        #endregion



        public mh_main()
        {
            InitializeComponent();
            //thuvien.Chuoi_CSDL = @"Data Source=RAD03\SQLEXPRESS;Initial Catalog=LPV_POS;User ID=sa; Password=sa" ;
            culture = CultureInfo.CurrentCulture;
            try
            {
                tv = new thuvien();

                if (System.IO.Directory.Exists(Application.StartupPath + "\\PDFFILE") == false)
                {
                    System.IO.Directory.CreateDirectory(Application.StartupPath + "\\PDFFILE");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Column 'Database' does not belong to table login.")
                    MessageBox.Show("Thông báo\nh_main()\n Vui lòng cấu hình lại CƠ SỞ DỮ LIỆU");
                else
                    MessageBox_LPV.Show("Thông báo\nh_main()\n" + ex.Message);
            }
        }

        private void mh_main_Load(object sender, EventArgs e)
        {
           
            cpublic cp = new cpublic();
            str_lang = cp.Registry_Get(this.Name + "_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            if (str_lang == "vi-VN")
                rad_viet.Checked = true;
            else
                rad_anh.Checked = true;

                Variable.ngay_gio_hienhanh = this.f_ngayhienhanh();
            timer1.Enabled = true;
            timer1.Interval = 1000;
            timer1.Tick += new EventHandler(timer1_Tick);
            //-- 20101015
            lbel_tencongty.Text = f_getnamecompany();

            
            //--------------------------------------------------------
            tb = f_dschunang();
            if (tb.Rows.Count > 0)
            {
                for (int i = tb.Rows.Count - 1; i >= 0; i--)
                {
                    switch (tb.Rows[i]["TEN_LABEL"] + "")
                    {
                        case "lbel_1":

                            set_datalabel(lbel_1, tb, i);
                            break;
                        case "lbel_2":
                            set_datalabel(lbel_2, tb, i);

                            break;
                        case "lbel_3":
                            set_datalabel(lbel_3, tb, i);

                            break;
                        case "lbel_4":
                            set_datalabel(lbel_4, tb, i);

                            break;
                        case "lbel_5":
                            set_datalabel(lbel_5, tb, i);

                            break;
                        case "lbel_6":
                            set_datalabel(lbel_6, tb, i);
                            break;
                        case "lbel_7":
                            set_datalabel(lbel_7, tb, i);
                            break;
                        case "lbel_8":
                            set_datalabel(lbel_8, tb, i);
                            break;
                        case "lbel_9":
                            set_datalabel(lbel_9, tb, i);
                            break;
                        case "lbel_10":
                            set_datalabel(lbel_10, tb, i);
                            break;
                        case "lbel_11":
                            set_datalabel(lbel_11, tb, i);
                            break;
                        case "lbel_12":
                            set_datalabel(lbel_12, tb, i);
                            break;
                    }
                }
            }
            #region "Muti language"

            cpublic ocpublic = new cpublic();
            str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);

            #endregion


            new cpublic().get_ngay_lam_viec();
            
            
            //string sSQL = "SELECT CHON = CAST(0 AS BIT), ten_form, ten_control, tag_control, menu_tieude FROM MENU";
            //Variable.tbMENU_QUYEN = new thuvien().SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new string[] { sSQL });
        }
        int count = 0;
        string t = new cpublic().Registry_Get("TIME_DONG_BO_SV");
        void timer1_Tick(object sender, EventArgs e)
        {
            count++;
            if (t == "")
                t = "200000"; 
            if (count >= int.Parse(t))
            {
                mh_dmkhachhang.dongboThrd();
                count = 0;
            }
           
            //Variable.ngay_gio_hienhanh = Variable.ngay_gio_hienhanh.AddSeconds(1);
            Variable.ngay_gio_hienhanh = this.f_ngayhienhanh();//----Chỉnh ngày giờ phần mềm khớp với hệ thống.---21/07/2012----
            lbel_ngayhienhanh.Text = Variable.ngay_gio_hienhanh.ToString("dd/MM/yyyy");
            lbel_giohienhanh.Text = Variable.ngay_gio_hienhanh.ToString("HH:mm:ss");
           // lbel_ngaylamviec.Text = "Ngày làm việc " + Variable.ngay_lamviec.ToString("dd/MM/yyyy");
            lbel_ngaylamviec.Text = lbel_ngaylamviec.Tag + " " + Variable.ngay_lamviec.ToString("dd/MM/yyyy");
            if (Variable.tbBH_CAU_HINH != null)
            {
                lbel_ngaylamviec.Visible = Variable.tbBH_CAU_HINH.Rows[0]["NGAY_LAM_VIEC_LA_NGAY_HE_THONG"] + "" != "True";
                lbel_NgayLamViec1.Visible = lbel_ngaylamviec.Visible;
            }
        }

        private void mh_main_MdiChildActivate(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild == null)
            {
                this.pnel_main.Visible = true;
            }
            else
            {
                this.pnel_main.Visible = false;
            }
        }

        private void lbel_banhang_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                string index = lbel_1.Tag.ToString().Substring(0, 1);
                label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_quanlykho_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_5.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_thoat_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_12.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_thuchi_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_9.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void label_danhmuc_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_10.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_caidat_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_2.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_hhtralai_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_7.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_baocao_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
            string index = lbel_3.Tag.ToString().Substring(0, 1);
            label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                MessageBox.Show(ex.Message);
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_VaoCa_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                string index = lbel_4.Tag.ToString().Substring(0, 1);
                label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void lbel_Raca_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                mh_so omh_so = new mh_so(true, "Thoát ca");
                string sUserName = omh_so.ShowFormS();
                if (omh_so.DialogResult != DialogResult.OK)
                    return;

                string sSQL = "SELECT top 1 ma "+
                              "FROM BH_LICHSU_CALAMVIEC "+
                              "WHERE ngay_gio_ra IS NULL "+
                              "     AND ca_ma = '" + sUserName + "' "+
                              "     AND TEN_MAY_TINH = '" + SystemInformation.ComputerName + "' "+
                              "ORDER BY ma DESC";

                DataTable tb = tv.SP_SelectDataTable("SP_EXECUTESQL",
                                                            new string[] { "@sSQL" },
                                                            new object[] { sSQL });
                if (tb.Rows.Count == 0)
                {
                   //2222222
                    switch (str_lang)
                    {
                        case "vi-VN":
                            str_thongbao = "Bạn chưa vào ca.";
                            break;
                        case "en-US":
                            str_thongbao = "You haven't gone in yet";
                            break;
                    }
                    MessageBox_LPV.Show(str_thongbao);
                    return;
                }
                
                if (omh_so.DialogResult == DialogResult.OK)
                {
                    //cap nhat GIO_RA
                    tv.SP_Update("sp_BH_LICHSU_CALAMVIEC",
                                            new string[] { "@flag", "@ma", "@TEN_MAY_TINH" },
                                            new object[] { 2, tb.Rows[0]["ma"], SystemInformation.ComputerName });

                    //load lai ca truoc do
                    sSQL = "SELECT dd.IQUYEN " +
                           "FROM DM_DANGNHAP dd " +
                           "WHERE dd.USERNAME IN " +
                           "    (	" +
                           "        SELECT TOP 1 blc.ca_ma	  " +
                           "        FROM BH_LICHSU_CALAMVIEC blc " +
                           "        WHERE blc.ngay_gio_ra IS NULL AND blc.TEN_MAY_TINH = '" + SystemInformation.ComputerName + "' " +
                           "        ORDER BY dd.OBJID DESC" +
                           "    )";
                    DataTable tbDM_DANGNHAP = tv.SP_SelectDataTable("SP_EXECUTESQL",
                                                                    new string[] { "@sSQl" },
                                                                    new object[] { sSQL });
                    Variable.iquyen = 0;
                    if (tbDM_DANGNHAP.Rows.Count > 0)
                    {
                        DataRow dr = tbDM_DANGNHAP.Rows[0];
                        Variable.iquyen = int.Parse("0" + dr["IQUYEN"]);
                    }
                }
                string index = lbel_6.Tag.ToString().Substring(0, 1);
                label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void lbel_8_Click(object sender, EventArgs e)
        {
            //-----------21/06/2012--------------------------------
            this.get_TrueFalseNGAY_LAM_VIEC();
            if (tbNGAYLAMVIEC == null || (tbNGAYLAMVIEC.Rows[0]["NGAY_LAM_VIEC_LA_NGAY_HE_THONG"] + "") != "True")
            {
                //-----------21/06/2012-------------------------------
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    string index = lbel_8.Tag.ToString().Substring(0, 1);
                    label_click(index);
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }
                this.Cursor = Cursors.Default;
            }
        }

        private void lbel_11_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                string index = lbel_11.Tag.ToString().Substring(0, 1);
                label_click(index);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
            this.Cursor = Cursors.Default;
        }

        private void mh_main_Activated(object sender, EventArgs e)
        {

            if (new cpublic().Registry_Get("LPV.configDongHo") == "True")
                {
                grpGauges.Visible = true;
                LPV.Gauges.DemosInfo.ShowModule(grpGauges);
            }
            else
                grpGauges.Visible = false;
        }

        private void rad_viet_CheckedChanged(object sender, EventArgs e)
        {
            cpublic cp = new cpublic();
            if (rad_viet.Checked)
            {
                cp.Registry_Set(this.Name + "_lang", "vi-VN");
                SetLanguage_banhang("vi-VN");
            }

            else
            {
                cp.Registry_Set(this.Name + "_lang", "en-US");
                SetLanguage_banhang("en-US");
            }
                


        }
        //---------21/06/2012----------------------
        #region " Lấy giá trị : True/false từ field NGAY_LAM_VIEC_LA_NGAY_HE_THONG"
        DataTable tbNGAYLAMVIEC = null;
        private void get_TrueFalseNGAY_LAM_VIEC()
        {
            string sSQL = "SELECT NGAY_LAM_VIEC_LA_NGAY_HE_THONG FROM BH_CAU_HINH";
            tbNGAYLAMVIEC = new thuvien().SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new object[] { sSQL });
        }
        #endregion
        //---------21/06/2012----------------------
    }
}